- @title = t('relationships.heading', person: link_to(@person.name, @person)).html_safe

.row
  .col-md-8
    - if @relationships.any?
      = form_tag batch_person_relationships_path(@person) do
        %table.table
          %tr
            %th
              %input{ onclick: "$('.outward_relationship_checkbox').attr('checked', this.checked)", type: "checkbox" }
            %th= t('name')
            %th
              = t('relationships.relationship')
            %th
              - @relationships.each do |relationship|
                %tr
                  %td= check_box_tag 'ids[]', relationship.id, false, class: 'outward_relationship_checkbox'
                  %td= link_to relationship.related.name, person_relationships_path(relationship.related)
                  %td= relationship.name_or_other
        .form-group.push-down
          = button_tag name: 'delete', data: { confirm: t('are_you_sure') }, class: 'btn btn-delete' do
            = icon 'fa fa-trash-o'
            = t('Delete')
          = button_tag name: 'reciprocate', class: 'btn btn-success' do
            = icon 'fa fa-exchange'
            = t('relationships.reciprocate.button')
    - else
      %p
        %em= t('none')

    = form_tag search_path, remote: true do
      = hidden_field_tag :select_person, true
      %p= t('relationships.add_relationship.intro')
      .form-group
        %label{ for: "name" }= t('search.search_by_name')
        = text_field_tag 'name', '', class: 'form-control'
      .form-group
        = button_tag t('relationships.add_relationship.button'), class: 'btn btn-info'
    #add_member{ style: "display:none;" }
      = form_tag person_relationships_path(@person) do
        .form-group
          %label{for: 'relationship_name'}= t('relationships.relationship_type')
          = select_tag :name, relationships_for_select, |
            id: 'relationship_name', |
            class: 'form-control', |
            include_blank: true, |
            data: { toggle: '#other_name', 'toggle-value' => 'other' }
        = text_field_tag :other_name, nil, |
          style: 'display:none;', |
          class: 'form-control', |
          placeholder: t('relationships.other_name.placeholder')
        #results
        .form-group
          = button_tag t('search.add_selected'), class: 'btn btn-success'

  .col-md-4
    .page-controls
      = link_to family_relationships_path(@person.family), class: 'btn btn-info' do
        = icon 'fa fa-group'
        = t('relationships.family.button')

    .box.box-info
      .box-header
        %h3.box-title= t('relationships.inward.heading')
      .box-body
        - if @inward_relationships.any?
          = form_tag batch_person_relationships_path(@person) do
            %table.table
              %tr
                %th
                  %input{ onclick: "$('.inward_relationship_checkbox').attr('checked', this.checked)", type: "checkbox" }
                %th= t('From')
                %th= t('relationships.relationship')
              - @inward_relationships.each do |relationship|
                %tr
                  %td= check_box_tag 'ids[]', relationship.id, false, class: 'inward_relationship_checkbox'
                  %td= link_to relationship.person.name, person_relationships_path(relationship.person)
                  %td= relationship.name_or_other
            .form-group.push-down
              = button_tag name: 'delete', data: { confirm: t('are_you_sure') }, class: 'btn btn-delete' do
                = icon 'fa fa-trash-o'
                = t('Delete')
              = button_tag name: 'reciprocate', class: 'btn btn-success' do
                = icon 'fa fa-exchange'
                = t('relationships.reciprocate.button')
        - else
          %p
            %em= t('none')
